#include <iostream>
#include "Entity.h"
#include "textdisplay.h"
#include "keyboardinput.h"
using namespace std;

Entity::Entity(EntityType type, string name)
{
    this->type = type;
    alive = true;
    health = 100;
    maxHealth = 100;
    magicPower = 100;
    maxMagicPower = 100;
    this->healthBar = TextBarMeter(maxHealth, health, 15, "Health");
    this->magicBar = TextBarMeter(maxMagicPower, magicPower, 15, "Magic");
    this->name = name;
    Animation *pThisAnimation = NULL;
    Sprite *pThisSprite = NULL;
}

Entity::~Entity()
{
    //dtor
}

void Entity::DisplayStats()
{
    cout << name << ":" << endl;
    healthBar.Display();
    cout << "    ";
    magicBar.Display();
    cout << endl << endl;
}

ActionType Entity::GetAction()
{
    KeyboardInput inputObject = KeyboardInput();
    ActionType selectedAction = inputObject.GetPlayerAction();
    return selectedAction;
}

bool Entity::ExecuteAction(ActionType action)
{
    cout << name << " does a thing" << endl;
    return true;
}

void Entity::SetSprite(Sprite *entitySprite)
{
    thisSpriteType = STATIC;
    pThisSprite = entitySprite;

}

void Entity::SetSprite(Animation *entityAnimation)
{
    thisSpriteType = ANIMATION;
    pThisAnimation = entityAnimation;
}

void Entity::Draw(Vector2 position)
{
    switch (thisSpriteType)
    {
    case STATIC:
        pThisSprite->Draw(position);
        break;
    case ANIMATION:
        pThisAnimation->Draw(position);
    }
}



